package com.chris.service.impl;

import com.chris.entity.SecurityUser;
import com.chris.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class JwtTokenUserDetailService implements UserDetailsService {
    @Autowired
    private LoginService loginService;
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        SecurityUser securityUser = loginService.loadByUsername(s);
        if(securityUser == null){
            throw new UsernameNotFoundException("用户不存在");
        }
        return securityUser;
    }
}
